using System;
using System.Linq;
using System.Reflection;

namespace UnitTesting.Fixturing
{
	class ParamTypesConstructorSelector<T> : ConstructorSelectorBase<T>
	{
		readonly Type[] _paramTypes;

		internal Type[] ParamTypes
		{
			get { return _paramTypes; }
		}

		internal ParamTypesConstructorSelector(Type[] paramTypes)
		{
			_paramTypes = paramTypes;
		}

		protected internal override ConstructorInfo Select(ConstructorInfo[] constructors)
		{
			return constructors.SingleOrDefault(
				x => x.GetParameters().Select(p => p.ParameterType).SequenceEqual(_paramTypes));
		}
	}
}